﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Factory
{
    public class DAOBase
    {
        //Passa string de conexao
        SqlConnection cnn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CSCONTABLIDADE"].ToString());

        //abre conexao se a mesma estiver fechada
        public SqlConnection CreateConnection()
        {
            if (cnn.State == ConnectionState.Closed)
            {
                cnn.Open();
            }

            return cnn;
        }

        //fecha conexao se a mesma estiver aberta
        public SqlConnection DestroyConnection()
        {
            if (cnn.State == ConnectionState.Open)
            {
                cnn.Close();
            }

            return cnn;
        }

    }
}
